package com.joke.mydiary;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Toast;

import com.joke.mydiary.utils.ChectNetUtil;

/**
 * 检测sd卡是否可用，如果不可用则结束程序
 */
public class SplashActivity extends Activity {

    private Handler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_splash);
        check();
    }


    public void check()
    {
        ChectNetUtil cnu=new ChectNetUtil();
        boolean externalFlag=cnu.isExternalStorageWritable();
        if(externalFlag)
        {
            handler=new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent=new Intent(SplashActivity.this,MainActivity.class);
                    startActivity(intent);
                    SplashActivity.this.finish();
                }
            },2000);
        }else {
            Toast.makeText(this,"请检查SD卡设置",Toast.LENGTH_LONG).show();
            finish();
        }
    }


}
